package com.summer.campussct.service.impl;

import com.summer.campussct.mapper.CampusOrShopMapper;
import com.summer.campussct.mapper.CategoryMapper;
import com.summer.campussct.pojo.CampusOrShop;
import com.summer.campussct.pojo.Category;
import com.summer.campussct.pojo.dto.RestResult;
import com.summer.campussct.service.IHomeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class HomeServiceImpl implements IHomeService {

    @Resource
    private CategoryMapper categoryMapper;

    @Resource
    private CampusOrShopMapper campusOrShopMapper;

    @Override
    public RestResult getHomeData() {
        //1. 查询车辆分类
        List<Category> vehicleCategoryList = categoryMapper.vehicleTypeList(10);
        //2. 查询一页学校
        List<CampusOrShop> campusList = campusOrShopMapper.campusList(10);
        //3. 查询一页店铺
        List<CampusOrShop> shopList = campusOrShopMapper.shopList(4);
        //4. 封装Map返回
        Map<String, Object> map = new HashMap<>();
        map.put("", vehicleCategoryList);
        map.put("vehicleList", vehicleCategoryList);
        map.put("campusList", campusList);
        map.put("shopList", shopList);
        return RestResult.success(map);
    }
}
